/*
 * OPIAM Suite
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package opiam.admin.faare.service.services.views.orgchart;

import java.util.Hashtable;

import javax.swing.JButton;
import javax.swing.tree.DefaultMutableTreeNode;


/*
 * Patch 2569 : nettoyage de code
 */

/**
 * This class implements an organization chart node.
 * This is merely a JButton with an associated node.
 */
public class XJButton extends JButton
{
    /** node associated with the button. */
    private DefaultMutableTreeNode node = null;

    /** parent orgchart object. */
    private OrgChartPanel parent;

    /**
     * Creates a new XJButton object.
     *
     * @param anode  Associated node.
     * @param aparent  Associated orgchart.
     */
    public XJButton(final DefaultMutableTreeNode anode,
        final OrgChartPanel aparent)
    {
        node = anode;

        parent = aparent;
        setBorderPainted(false);
    }

    /**
     * Converts the object to a String representation.
     *
     * @return String representation of the object.
     */
    @Override
	public final String toString()
    {
        Hashtable info = (Hashtable) node.getUserObject();

        return (String) info.get(OrgChartPanel.NAME);
    }

    /**
     * Gets associated node.
     *
     * @return  The associated node.
     */
    public final DefaultMutableTreeNode getNode()
    {
        return node;
    }
}
